import Instance from '@/utils/http.ts';
import {RouteParamValue} from "vue-router";


// 修改一条进场数据
export function useModifyOneAPI(formData:FormData){
    return Instance({
        url:'/material-in/modifyOne',
        method:'PUT',
        headers: {
            'content-type': 'multipart/form-data'
        },
        data:formData
    })
}

//  新增一条进场数据
export function useSaveOneMaterialInAPI(formData:FormData) {
    return Instance({
            url: `/material-in/saveOne`,
            method: 'POST',
            headers:{
                'content-type': 'multipart/form-data'
            },
            data:formData
        }
    )
}

// 分页获取所有材料进场表单记录
export function useGetAllMaterialInAPI(current:number,pageSize:number){
    return Instance({
        url:'/material-in/getAllByPage',
        method:'GET',
        params: {current: current, pageSize: pageSize}
    })
}

//配合获取所有材料进场表单记录接口，获取所有材料进场表单记录条数
export function useGetAllMaterialInCountsAPI(){
    return Instance({
        url:'/material-in/getAllCounts',
        method:'GET'
    })
}

// 多功能名称查询接口
export function useGetAllByMultifunctionNameAPI(name:string,current:number,pageSize:number){
    return Instance({
        url:'/material-in/getAllByMultifunctionName',
        method:'GET',
        params:{
            name,current,pageSize
        }
    })
}

// 配合多功能查询接口获取数据条数
export function useGetAllCountsByMultifunctionNameAPI(name:string,current:number,pageSize:number){
    return Instance({
        url:'/material-in/getAllCountsByMultifunctionName',
        method:'GET',
        params:{
            name,current,pageSize
        }
    })
}

// 根据时间段查询数据
export function useGetByBetweenTimesAPI(start:Date,end:Date, current:number,pageSize:number){
    return Instance({
        url:'/material-in/getByBetweenTimes',
        method:'GET',
        params:{
            start,end,current,pageSize
        }
    })
}
// 配合根据时间段查询数据接口，获取所有数据条数
export function useGetAllCountsByBetweenTimesAPI(start:Date,end:Date){
    return Instance({
        url:'/material-in/getAllCountsByBetweenTimes',
        method:'GET',
        params:{
            start,end
        }
    })
}

// 通过id删除一套数据
export function useDeleteOneByIdAPI(id:number) {
    return Instance({
            url: `/material-in/${id}`,
            method: 'DELETE',
        }
    )
}
// 下载文件，并打包成一个zip文件
export function useDownloadFileListAPI(files:[]) {
    return Instance({
            url: `/material-in/downLoadFiles`,
            method: 'POST',
            data:files,
            responseType:'blob'
        }
    )
}
// 添加一个材料进场数据
export function useSaveOneMaterialInFormAPI(formData:FormData) {
    return Instance({
            url: `/material-in/saveNewOne`,
            method: 'POST',
            data:formData,
        headers:{
            'content-type': 'multipart/form-data'
        },
        }
    )
}

// 根据id获取一条数据信息
export function useGetOneByIdAPI(id: string | RouteParamValue[]){
    return Instance({
        url:`/material-in/${id}`,
        method:'GET'
    })
}



export function useGetMaterialInListByMaterialId(timeStatus:boolean, materialId:number,current:number,pageSize:number,projectName:string,start:string,end:string) {
    return Instance({
        url:`/material-in/getMaterialInListByMaterialId`,
        method:'GET',
        params:{
          timeStatus, materialId,current,pageSize,projectName,start,end
        }
    })
}

export function useGetMaterialInListCountsByMaterialId(timeStatus:boolean, materialId:number,projectName:string,start:string,end:string){
    return Instance({
        url:`/material-in/getMaterialInListByMaterialIdCounts`,
        method:'GET',
        params:{
           timeStatus, materialId,projectName,start,end
        }
    })
}

























